package org.vergil.core.mq.springMq;

import org.springframework.stereotype.Component;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

/**
 * Created by vergil on 3/2/17.
 */
@Component
public class ConsumerMessageListener implements MessageListener {
    public void onMessage(Message message) {
        // 监听发送到消息队列的文本消息，作强制转换。
        TextMessage textMessage = (TextMessage) message;
        try {
            System.out.println("接收到的消息内容是：" + textMessage.getText());
            // TODO: 你喜欢的任何事情...
        } catch (JMSException e) {
        }
    }
}
